{include file="common/head"/}
<div class="main2"> 
    <div class="layui-card-header"><i class="layui-icon">&#xe60b;</i>订单信息</div>
    <div class="layui-card-body payinfo">
        <div class="orderid">
            <span class="name">订单号：</span>
            <span class="ordernum"><input id="orderidss" style="border:none; width: 150px;" value="{$order.orderid}"><!--div class="layui-btn layui-btn-xs layui-btn-normal" id="copys">复制</div--></span>
        </div>
         <!-- <div class="orderid"><span class="red">提示：您在转款时，请务必备注该订单号。</span></div> -->
        <div class="orderid">
            <span class="name">支付金：</span> 
            <span class="ordernum">{$order.money}</span><span class="name">元</span>
        </div>
        <div class="orderid">
            <span class="name">产品名：</span> 
            <span class="name">{$order.cionname}({$order.price}*{$order.number}份)</span>
        </div>
        {if $order['name_en']=='Bank'} 
        	<div class="orderid">
	            <span class="name">收款方式：</span> 
	            <span class="ordernum">{$order.name}（{$order.bank_name}）</span>
	        </div>
        	<div class="orderid">
	            <span class="name">收款账号：</span>  
	            <span class="name"><input id="bank_no" style="border:none; width: 150px;" value="{$order.bank_no}">（{$order.content}）<div class="layui-btn layui-btn-xs layui-btn-normal" id="copy">复制</div></span>
	        </div> 
            <div class="paybanks">
            {volist name="paybanks" id="vo"}
                <li><a href="{$vo.url}" target="_blank" title="{$vo.name}"><img src="{$vo.pic}"></a></li>
            {/volist}
            </div>
        {else}
        	<div class="orderid">
	            <span class="name">收款方式：</span> 
	            <span class="ordernum">{$order.name}</span>
	        </div>
        	<div class="orderid">
	            <span class="name">收款账号：</span> 
	            <span class="name"><input id="bank_no" style="border:none; width: 150px;" value="{$order.bank_no}">（{$order.bank_name}）<div class="layui-btn layui-btn-xs layui-btn-normal" id="copy">复制</div></span>
	        </div>  
        	<div class="paycode"><div class="picbox"><img src="{$order.qrcode}" width="190" height="190"></div></div> 
           
        {/if} 
       <!--  <div class="orderid"><span class="red">完成付款后，请返回此页面点击此按钮。</span></div>
        <div class="orderid"><span class="red">没有付款，请勿点击此按钮。</span></div>
        <div class="paybot"> 
            <button type="submit" class="layui-btn layui-btn-fluid" lay-filter="paysub" lay-submit>完成付款后，点击确认111111</button>
        </div> -->
    </div> 
</div>  
<script src='https://cdn.bootcss.com/socket.io/2.0.3/socket.io.js'></script>
<script> 
layui.use(['layer','jquery','form'], function(){
    $ = layui.jquery;
    var form = layui.form, layer = layui.layer;   
    // layer.msg('请务必在付款时，备注该订单号！'); 
    //提交监听
    form.on('submit(paysub)', function (data) {
        var loading = layer.load(1, {shade: [0.1, '#fff']});  
        $.post("{$sys.url}{:url('pay/view/doit')}",{orderid:"{$order.orderid}",appid:"{$order.shopappid}",sign:"{$order.sign}"},function(res){
            layer.close(loading);
            if(res.code===1){
                layer.msg(res.msg,{time:2000,icon:1},function(){  
                    location.href = res.callbackurl;  
                });
            }else{
                layer.msg(res.msg,{time:1000,icon:0}); 
            }
        });
        return false;
    });
    var content='{$order.userid}|{$order.agentid}'
    var pushurl="http://"+document.domain+":2121/?type=publish&content="+content;
    $.get(pushurl); 
    $('#copy').on('click', function () { 
        var e=document.getElementById("bank_no");//对象是contents 
        console.log(e);
        e.select(); //选择对象 （全选）
        document.execCommand("Copy"); //执行浏览器复制命令 
        layer.msg('复制成功'); 
    }); 
    $('#copys').on('click', function () { 
        var e=document.getElementById("orderidss");//对象是contents 
        console.log(e);
        e.select(); //选择对象 （全选）
        document.execCommand("Copy"); //执行浏览器复制命令 
        layer.msg('复制成功'); 
    });  

});


var int=self.setInterval("checkorder()",5000);
function checkorder()
{
    var orderid="{$order.orderid}";
    var shopappid="{$order.shopappid}";
    var sign="{$order.sign}";
    // alert(shopappid);
    $.ajax({
            type: "POST",
            url: "{:url('pay/view/checkorder')}",
            data: {
                orderid:orderid,
                shopappid:shopappid,
                sign:sign,
            },
            dataType: "json",
            success: function(data){
                // console.log(data);
                if(data.code===1){
                    alert(data.msg);
                    location.href = data.callbackurl; 
                }
            }
         });
}

</script>  
</body>
</html>